﻿using System.Linq;
using Nancy;
using Nancy.Routing;

namespace API_Service
{
    public class DocModule : NancyModule
    {
        private IRouteCacheProvider _routeCacheProvider;

        public DocModule(IRouteCacheProvider routeCacheProvider):base("/docs")
        {
            this._routeCacheProvider = routeCacheProvider;

            Get["/"] = _ =>
            {
                var routeDescriptionList = _routeCacheProvider
                                           .GetCache()
                                           .RetrieveMetadata<MyRouteMetadata>()
                                           .Where(x => x != null);

                return Response.AsJson(routeDescriptionList);
            };
           
        }
    }
}